package com.ruoyi.project.websitenewstrends.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.websitenewstrends.mapper.WebsiteNewsTrendsMapper;
import com.ruoyi.project.websitenewstrends.domain.WebsiteNewsTrends;
import com.ruoyi.project.websitenewstrends.service.IWebsiteNewsTrendsService;
import com.ruoyi.common.utils.text.Convert;

/**
 * newstrendsService业务层处理
 * 
 * @author lvyongwei
 * @date 2021-04-20
 */
@Service
public class WebsiteNewsTrendsServiceImpl implements IWebsiteNewsTrendsService 
{
    @Autowired
    private WebsiteNewsTrendsMapper websiteNewsTrendsMapper;

    /**
     * 查询newstrends
     * 
     * @param newsId newstrendsID
     * @return newstrends
     */
    @Override
    public WebsiteNewsTrends selectWebsiteNewsTrendsById(Long newsId)
    {
        return websiteNewsTrendsMapper.selectWebsiteNewsTrendsById(newsId);
    }

    /**
     * 查询newstrends列表
     * 
     * @param websiteNewsTrends newstrends
     * @return newstrends
     */
    @Override
    public List<WebsiteNewsTrends> selectWebsiteNewsTrendsList(WebsiteNewsTrends websiteNewsTrends)
    {
        return websiteNewsTrendsMapper.selectWebsiteNewsTrendsList(websiteNewsTrends);
    }

    /**
     * 新增newstrends
     * 
     * @param websiteNewsTrends newstrends
     * @return 结果
     */
    @Override
    public int insertWebsiteNewsTrends(WebsiteNewsTrends websiteNewsTrends)
    {
        if(websiteNewsTrends.getCreateTime() == null){
            websiteNewsTrends.setCreateTime(DateUtils.getNowDate());
        }
        return websiteNewsTrendsMapper.insertWebsiteNewsTrends(websiteNewsTrends);
    }

    /**
     * 修改newstrends
     * 
     * @param websiteNewsTrends newstrends
     * @return 结果
     */
    @Override
    public int updateWebsiteNewsTrends(WebsiteNewsTrends websiteNewsTrends)
    {
        websiteNewsTrends.setUpdateTime(DateUtils.getNowDate());
        return websiteNewsTrendsMapper.updateWebsiteNewsTrends(websiteNewsTrends);
    }

    /**
     * 删除newstrends对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteWebsiteNewsTrendsByIds(String ids)
    {
        return websiteNewsTrendsMapper.deleteWebsiteNewsTrendsByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除newstrends信息
     * 
     * @param newsId newstrendsID
     * @return 结果
     */
    @Override
    public int deleteWebsiteNewsTrendsById(Long newsId)
    {
        return websiteNewsTrendsMapper.deleteWebsiteNewsTrendsById(newsId);
    }


    /**
     * 获取轮播的新闻信息
     * @return
     */
    @Override
    public List<WebsiteNewsTrends> getPlayNewsTrends(){
        return websiteNewsTrendsMapper.getPlayNewsTrends();
    }

    /**
     * 获取新闻动态分页
     * @return
     */
    @Override
    public List<WebsiteNewsTrends> getAllNewsTrends() {
        return websiteNewsTrendsMapper.getAllNewsTrends();
    }
}
